<!DOCTYPE html>
<!--[if IE 8]> <html lang="zh-CN" class="ie8"> <![endif]-->
<html lang="zh-CN">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>申请退款</title>
		<meta content="telephone=no,email=no,address=no" name="format-detection" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta name="msapplication-tap-highlight" content="no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="wap-font-scale" content="no">
		<meta name="Keywords" content="" />
		<meta name="Description" content="" />
		<link rel="stylesheet" href="/themes/wnsc_moblie/newMobile/User/css/common.css" />
		<link rel="stylesheet" href="/themes/wnsc_moblie/newMobile/User/css/user.css" />
		<link rel="stylesheet" href="/themes/wnsc_moblie/newMobile/User/css/color-style.css" />
		<link rel="stylesheet" type="text/css" href="/themes/wnsc_moblie/Public/css/public.css">
		<link rel="stylesheet" type="text/css" href="/themes/wnsc_moblie/newMobile/User/css/back.css" />
		<script type="text/javascript" src="/themes/wnsc_moblie/newMobile/User/js/area/jquery.min.js"></script>
		<script type="text/javascript" src="/themes/wnsc_moblie/Public/js/common.js"></script>
		<script src="/themes/wnsc_moblie/newMobile/Shop/js/layer.js"></script>

	</head>

	<body>
	<?php
				$agent = $_SERVER['HTTP_USER_AGENT'];
				if(strpos($agent,"Html5Plus") === false){
			?>
		<header>
			<div class="tab_nav">
				<div class="header">
					<div class="header-left">
						<a class="sb-back" href="javascript:history.back(-1)" title="返回"></a>
					</div>
					<div class="header-middle">申请退款</div>
					<div class="header-right">
						<aside class="show-menu-btn">
							<div class="show-menu" id="show_more">
								<a href="javascript:;"></a>
							</div>
						</aside>
					</div>
				</div>
			</div>
		</header>
		<mtc_include file="Public:right_nav" />
	<?php
			}
			?>
		<form class="main mt-45">
			<div class="return-process">
				<ul class="clear">
					<li class="step01 current">
						<p class="name">买家申请退款</p> <span class="number">1</span> <span class="prcess-line prcess-line-r"></span>
					</li>
					<li class='step02 <egt name="order_info['refund_state']" value="2" >current</egt>' >
						<p class="name">商家处理退款申请</p> <span class="prcess-line prcess-line-l"></span>
						<span class="number">2</span> <span class="prcess-line prcess-line-r"></span>
					</li>
					<li class='step03 <egt name="order_info['refund_state']" value="5" >current</egt>'>
						<p class="name">退款完成</p> <span class="prcess-line prcess-line-l"></span>
						<span class="number">3</span>
					</li>
				</ul>
			</div>
			<div class="form-c" id="form1">
				<php>if($order_info['refund_state']==0){</php>
				<div class="row">
					<div class="small-12 columns">
						<label><span class="color-red">*</span>处理方式：</label>
						<div class="columns-select">
							<select id="refund_require">
								<option value="1" selected="selected">我要退款，但不退货</option>
								<option value="2">我要退款退货</option>
							</select>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="small-12 columns">
						<label><span class="color-red">*</span>退款原因：</label>
						<div class="columns-select">
							<select id="refund_reason">
								<option value="买/卖双方协商一致">买/卖双方协商一致</option>
								<option value="买错/多买/不想要">买错/多买/不想要</option>
								<option value="商品质量问题">商品质量问题</option>
								<option value="未收到货品">未收到货品</option>
								<option value="其他">其他</option>
							</select>
						</div>
					</div>
				</div>
				<php>$price=get_count_price($order_info['order_sn']);</php>
				<div class="row">
					<div class="small-12 columns">
						<label><span class="color-red">*</span>退款金额：</label>
						<div class="columns-input">
							<input value="" id="refund_money" class="maxRefund" type="text" placeholder="最多可退款{$price}元" onblur="maxRefund()">
							<input value="{$price}" id="maxRefundMoney" type="hidden">
						</div>
					</div>
				</div>
				<div class="clear"></div>
				<div class="row description_dl">
					<div class="small-12 columns" style="background-color:#f5f5f5;">
						<label>退款说明：</label>
					</div>
				</div>
				<textarea rows="5" id="description" class="description_dl" style="padding:5px 15px;"></textarea>
				<a class="button" href="javascript:void(0)" onclick="btnSave()">提交退款申请</a>
				<php>}else{</php>
					<div class="row">
						<div class="small-12 columns">
							<label><span class="color-red">*</span>处理方式：</label>
							<div class="columns-select" style="line-height: 44px;">
									<eq name="order_info['refund_type']" value="1"> 我要退款，但不退货  </eq>
									<eq name="order_info['refund_type']" value="2"> 我要退款退货</eq>
							</div>
						</div>
					</div>
					<div class="clear"></div>
					<div class="row">
						<div class="small-12 columns">
							<label><span class="color-red">*</span>退款原因：</label>
							<div class="columns-select" style="line-height: 44px;">
									{$order_info['refund_reason']}
							</div>
						</div>
					</div>
					<div class="clear"></div>
					<div class="row">
						<div class="small-12 columns">
							<label><span class="color-red">*</span>退款金额：</label>
							<div class="columns-select" style="line-height: 44px;">
									{$order_info['refund_amount']}
							</div>
						</div>
					</div>	
					
					<gt name="order_info['refund_state']" value="1">
						<div class="clear"></div>
						<div class="row">
							<div class="small-12 columns">
								<label><span class="color-red">*</span>卖家处理：</label>
								<div class="columns-select" style="line-height: 44px;">
										<eq name="order_info['refund_state']" value="2"> 同意 </eq>
										<eq name="order_info['refund_state']" value="3">  店铺拒绝 &nbsp;（官方提示:您还可以联系网站客服处理，400-870-3150   周一至周五(9:00-22:00)）</eq>
										<eq name="order_info['refund_state']" value="4"> 等待客服打款</eq>
										<eq name="order_info['refund_state']" value="5"> 打款成功</eq>
								</div>
							</div>
						</div>
					</gt>
					<eq name="order_info['refund_state']" value="2"> 
						<eq name="order_info['refund_type']" value="2">
							<div class="clear"></div>
							<div class="row">
								<div class="small-12 columns">
									<label><span class="color-red">*</span>退货物流：</label>
									<div class="columns-select" style="line-height: 44px;">
										<php>$exprsss=get_express();</php>
											
											<input class="inputBg wuliu_number" type="text" placeholder="物流单号" value="{$order_info['refund_shipping_code']}">
											<select name="exprsss" id="wuliu_express"style="height: 28px;border-color: #ddd;">
												<option value="0">请选择物流公司</option>
												<foreach name="exprsss" item="v">
													<option value="{$v.express_no}" <eq name="order_info['refund_shipping_company_id']" value="$v['express_no']">selected</eq>>{$v.company_name}</option>
												</foreach>
											</select><br/>
											<input type="button" name="return_wuliu" id="return_wuliu" value="提交" />
									</div>
								</div>
							</div>
							
						</eq>
					</eq>
								
					<php>}</php>
			</div>
		</form>
		<script type="text/javascript" src="/themes/wnsc/Public/js/jquery.min.js"></script>
		<script src="/themes/wnsc_moblie/newMobile/Shop/js/layer.js"></script>
		<script type="text/javascript" src="/themes/wnsc/Public/js/jquery.method.js"></script>

		<script type="text/javascript">
			var order_id={$_GET['order_id']};
			$(function() {
				//如果退款原因是选择的其他就让用户自己写退款说明
				$("#refund_reason").change(function() {
					if($(this).val() == "其他") {
						$('.description_dl').show();
					} else {
						$('.description_dl').hide();
					}
				});
				
				$("#return_wuliu").click(function(){
					var wuliu_number=$('.wuliu_number').val();
					var wuliu_express=$('#wuliu_express').val();
					var wuliu_express_name=$("#wuliu_express").find("option:selected").text();
				
					if(!wuliu_number) {
						$(".wuliu_number").focus();
						$.msg("请填写物流单号");
						return false;
					}
					if(wuliu_express==0) {
						$("#wuliu_express").focus();
						$.msg("请选择物流公司");
						return false;
					}
				
					$.ajax({
						url: "{:U('user/refunddetail_update')}",
						type: "post",
						data: {
							"order_id": order_id,
							"wuliu_number": wuliu_number,
							"wuliu_express": wuliu_express,
							"wuliu_express_name": wuliu_express_name,
						},
						dataType: "json",
						success: function(response) {
							if(response.code > 0) {
								$.msg(response.message);
								setTimeout("window.location.reload();",1000)
								
							} else {
								$.msg(response.message);
							}
						}
					});
					
				})

			})
			
			//保存退款信息
			function btnSave() {
				var refund_require = $("#refund_require").val();
				var refund_reason = $("#refund_reason").val();
				var refund_money = $("#refund_money").val(); //退款金额
				var description = $("#description ").val(); //
				var maxRefundMoney = parseFloat($("#maxRefundMoney").val());
				if(refund_money != 0) {
					if(refund_money <= 0 || refund_money > maxRefundMoney) {
						$("#refund_money").focus();
						$.msg("超出可退款金额范围");
						return false;
					}
				} else {
					$("#refund_money").focus();
					$.msg("请输入退款金额");
					return false;
				}
				if($('#refund_reason').val() == '其他') {
					refund_reason = description;
				}
				$.ajax({
					url: "{:U('user/refunddetail_save')}",
					type: "post",
					data: {
						"order_id": order_id,
						"refund_type": refund_require,
						"refund_require_money": refund_money,
						"refund_reason": refund_reason,
					},
					dataType: "json",
					success: function(response) {
						if(response.code > 0) {
							$.msg(response.message);
							setTimeout("window.location.reload();",1000)
							
						} else {
							$.msg(response.message);
						}
					}
				});
			}
			function maxRefund(){
				var refund_money = $("#refund_money").val(); //退款金额
				var maxRefundMoney = parseFloat($("#maxRefundMoney").val());
				if(refund_money != 0) {
					if(refund_money <= 0 || refund_money > maxRefundMoney) {
						$("#refund_money").focus();
						$.msg("超出可退款金额范围");
						return false;
					}
				} else {
					$("#refund_money").focus();
					$.msg("请输入退款金额");
					return false;
				}
			}
		</script>
	</body>

</html>